# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=portmidi
pkgver=2.0.4
pkgrel=1
epoch=1
pkgdesc="Cross platform library for interfacing with OS MIDI I/O APIs"
arch=(x86_64)
url="https://github.com/portmidi/portmidi"
license=(MIT)
depends=(
  glibc
)
makedepends=(
  alsa-lib
  cmake
)
provides=(
  libportmidi.so
)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('d9f22d161e1dd9a4bde1971bb2b6e5352da51545f4fe5ecad11c55e7a535f0d88efce18d1c8fd91e93b70a7926150f86a0f53972ad92370e86556a8dd72dc194')
b2sums=('fd8b002880ccfcff9f233e2fa5021fe4cf9da2f91b3ceaa36fe70f96818e174578f9a14b69bdbb58fab777c9a9e4ff939b86814a403860c7ec264dddc6f26e85')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=None
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  depends+=(
    alsa-lib libasound.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/license.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 $pkgname-$pkgver/{CHANGELOG,README}.txt -t "$pkgdir/usr/share/doc/$pkgname/"
}
